package com.samphanie.auiu.demo.refresh;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.os.Handler;
import android.view.View;

import com.samphanie.auiu.R;
import com.samphanie.auiu.ui.refresh.AuiuOverView;
import com.samphanie.auiu.ui.refresh.AuiuRefresh;
import com.samphanie.auiu.ui.refresh.AuiuRefreshLayout;
import com.samphanie.auiu.ui.refresh.AuiuTextOverView;

public class AuiuRefreshDemoActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_auiu_refresh_demo);

        // 自定义下拉刷新动画效果
        // AuiuTextOverView xOverView = new AuiuTextOverView(this);
        AuiuLottieOverView xOverView = new AuiuLottieOverView(this);
        AuiuRefreshLayout refreshLayout = findViewById(R.id.refresh_layout);
        refreshLayout.setRefreshOverView(xOverView);

        refreshLayout.setRefreshListener(new AuiuRefresh.AuiuRefreshListener() {
            @Override
            public void onRefresh() {
                new Handler().postDelayed(refreshLayout::refreshFinished, 1000);
            }

            @Override
            public boolean enableRefresh() {
                return true;
            }
        });
        refreshLayout.setDisableRefreshScroll(false);
    }
}